<?php namespace app\admin\controller;

use houdunwang\route\Controller;
use houdunwang\request\Request;
use system\model\Base as BaseModel;

class Base extends Common {

	//通过中间件控制局部可控制性
	public function __construct()
	{
		$this->auth();
	}

	//动作
    public function index(){
        //此处书写代码...
		//return view();
    }

    public function setting(BaseModel $base)
	{
		if(IS_POST)
		{
			$base->setBase(Request::post());
			return $this->setRedirect('refresh')->success('操作成功');
		}
		//获取数据库的数据
		$model = BaseModel::find(22);
		//如果能找到数据，将其转为数组，分配到页面
		//如果找不到数据，默认给空数组
		//$field_contern 是关注回复
		//$field_default 是默认回复
		$field_contern = $model ? json_decode($model['base_contern'],true):[];
		$field_default = $model ? json_decode($model['base_default'],true):[];
		//
		return view('',compact('field_contern','field_default'));
	}
}
